#
# Script for migration of Maxmind GeoCity Lite to geomydns
# Scripted by Evan Park <inblaze@gmail.com>, 2007/12/27
# 
#!/bin/sh

MYSQL_USER=
MYSQL_PASSWD=
MYSQL_DBNAME=mydns
MYSQL_DATA_DIR=/opt/mysql/data
MYSQL_IMPORT=/opt/mysql/bin/mysqlimport
MYSQL=/opt/mysql/bin/mysql
GEOCITY_BLOCKS_CSV=geocity_blocks.csv
GEOCITY_LOCS_CSV=geocity_locs.csv

### INPUT to geoip_csv table ###
cp $GEOCITY_BLOCKS_CSV $MYSQL_DATA_DIR/$GEOCITY_BLOCKS_CSV
$MYSQL_IMPORT --fields-terminated-by="," \
--fields-optionally-enclosed-by="\"" \
--lines-terminated-by="\n" \
--host=localhost \
--user=$MYSQL_USER \
--password=$MYSQL_PASSWD \
$MYSQL_DBNAME ./$GEOCITY_BLOCKS_CSV
rm $MYSQL_DATA_DIR/$GEOCITY_BLOCKS_CSV

cp $GEOCITY_LOCS_CSV $MYSQL_DATA_DIR/$GEOCITY_LOCS_CSV
$MYSQL_IMPORT --fields-terminated-by="," \
--fields-optionally-enclosed-by="\"" \
--lines-terminated-by="\n" \
--host=localhost \
--user=$MYSQL_USER \
--password=$MYSQL_PASSWD \
$MYSQL_DBNAME ./$GEOCITY_LOCS_CSV
rm $MYSQL_DATA_DIR/$GEOCITY_LOCS_CSV

echo "Migration Done."
